Skip to content

Ensure every mocks payload folder has a 404 case - #340

Merged
Samuelfaure merged 3 commits into
developfrom
worktree-mocks-payloads-404
Aug 21, 2026
Merged

Ensure every mocks payload folder has a 404 case#340
Samuelfaure merged 3 commits into
developfrom
worktree-mocks-payloads-404

Conversation

@Samuelfaure

@Samuelfaure Samuelfaure commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 21 of 107 mocks/payloads/ endpoint folders had no not-found test case. Investigated each: for 14 of them the OpenAPI spec already documented a 404 (payload written straight from the spec's example); for the remaining 7 (api_entreprise_v3_dgfip_tva and all 6 cnous_etudiant_boursier v4/v5 variants) the spec simply never documented one, even though the underlying siade interactors already produce a NotFoundError in that case.
  • Fixed the 7 undocumented cases at the source: added the missing response '404' rswag blocks to the siade request specs (mirroring sibling/prior-version endpoints), added a WebMock "not found" stub for DGFIP TVA, and regenerated commons/swagger/*.yaml so the public OpenAPI docs now match actual behavior.
  • Added the corresponding 404.yaml to all 21 folders and regenerated their READMEs.
  • Updated the siade-sync-openapi-payloads skill so future syncs always check 404 coverage (not just missing folders) and know to fix an undocumented-but-real 404 at the siade/rswag level instead of skipping it.

DGFIP::TVA::ValidateResponse and both CNOUS student-scholarship
interactors already return a NotFoundError on an empty provider
response, but the rswag request specs never documented a 404 case
for these endpoints (the v4/v5 CNOUS specs were cloned from v3 with
only the 200 path). Add the missing response blocks and regenerate
the OpenAPI docs so the public spec matches actual behavior.
21 of 107 endpoint folders had no not-found test case. Add a
404.yaml to each, matching the (now complete, see previous commit)
OpenAPI documentation for that operation, and regenerate the
per-folder READMEs.
The skill only checked for missing payload folders, not for folders
that exist but lack a 404 case, and it told agents to skip 404
whenever the OpenAPI spec didn't document it. Since NotFoundError is
a universal error every SIADE interactor can emit, an undocumented
404 is almost always a spec gap, not a real absence of the case.

Add a step to check 404 coverage on existing folders, and replace
the skip-if-undocumented rule with instructions to check the
interactor code and, if it does call resource_not_found!, fix the
rswag spec and regenerate the OpenAPI docs before writing the mock.
@Samuelfaure
Samuelfaure requested review from Un3x and skelz0r August 21, 2026 08:20

@skelz0r skelz0r left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vis-à-vis du premier commit, je pense que ça serait plus intelligent de juste augmenter les swaggers post générations, y'a pas de plu-value à les générer via rswag.

C'est du détail, mais ça mérite d'être mentionné pour qu'à l'avenir on simplifie ce qu'on peut simplifier.

@Samuelfaure

Copy link
Copy Markdown
Contributor Author

Ça se débat mais je trouve que c'est mieux comme ça en vrai, les tests RSwag servent de référence, augmenter le fichier openAPI ailleurs c'est + complexe pour un gain minimal

@Samuelfaure
Samuelfaure merged commit 1ba2042 into develop Aug 21, 2026
3 checks passed
@Samuelfaure
Samuelfaure deleted the worktree-mocks-payloads-404 branch August 21, 2026 09:06
@skelz0r

skelz0r commented Aug 21, 2026

Copy link
Copy Markdown
Member

On le fait déjà https://github.com/datagouv/apistration/blob/develop/siade/bin/augment_openapi_files.rb, et en vrai je trouve que c'est plus logique de mettre tous les trucs génériques (400, 401, 403, 404, 502) dans un post processing plutôt que de faire tourner la stack. Si il y a de la logique métier c'est cohérent de faire tourner la stack pour la capturer, là y'a aucun intérêt.

D'ailleurs limite on pourrait retirer 400/401/403 (voir 404/502) de notre swagger vu que c'est normalisé

@Samuelfaure

Copy link
Copy Markdown
Contributor Author

Pour moi les 404 y'a une logique métier non? 🤔

@skelz0r

skelz0r commented Aug 21, 2026

Copy link
Copy Markdown
Member

Pour moi les 404 y'a une logique métier non? 🤔

Dans certains cas (genre CNAF/MSA où t'as des sous-codes), mais majoritairement c'est "On n'a rien trouvé", et ça peut s'auto-complète avec un post processing. C'est du cas par cas.

Mon point ici est que dans le RSwag on complète les cas métiers qu'on veut mettre en avant pour que ça transparaisse dans le swagger, et le post processing s'occupe des boring stuffs.
On s'économise ~5 tests E2E / endpoints du coup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants